#include <vector>
using namespace std;
class Solution
{
public:
    vector<int> singleNumber(vector<int> &nums)
    {
        int s = 0;
        int len = nums.size();
        for (int i = 0; i < len; i++)
        {
            s ^= nums[i];
        }
        int mask = 1;
        while ((s & mask) == 0)
        {
            mask <<= 1;
        }
        int a = 0, b = 0;
        for (int i = 0; i < len; i++)
        {
            if ((nums[i] & mask) == 0)
            {
                a ^= nums[i];
            }
            else
            {
                b ^= nums[i];
            }
        }
        return vector<int>{a, b};
    }
};